<template>
    <div>
      <Content style="width:90%">
        <Form :label-width="140">
          <FormItem label="分组名称" required>
            <Input v-model="dataForm.groupName" placeholder="请输入分组名称"/>
          </FormItem>
          <FormItem label="分组类型" required>
            <RadioGroup v-model="dataForm.groupCode">
              <Radio label="DEF"><span>普通分组</span></Radio>
              <Radio label="FLASH.SALE"><span>限时抢购</span></Radio>
            </RadioGroup>
          </FormItem>
          <FormItem label="排序" required>
            <InputNumber :min="1" v-model="dataForm.sortIndex" placeholder="请输入排序"></InputNumber>
          </FormItem>
          <FormItem label="是否启用">
            <Select v-model="dataForm.groupStatus">
              <Option :value="0" key="0">关闭</Option>
              <Option :value="1" key="1">开启</Option>
            </Select>
          </FormItem>
          <FormItem>
            <Button type="primary" @click="Submit">提交</Button>
          </FormItem>
        </Form>
      </Content>
    </div>
</template>
<script>
export default {
  name: "GroupCreate",
  props: {
    callbank: Function
  },
  data() {
    return {
      dataForm: {
        groupCode: 'DEF',
        appCode: 'agromall',
        groupStatus: 0,
        sortIndex: 1
      }
    }
  },
  created() {
    
  },
  methods: {
    Submit() {
      new this.$rest({
        gateway: 'agroerp',
        service: "agroerp-mall",
        url: "/v1.0/goods/group",
        data: {
          pojo: this.dataForm
        },
        action: (res) => {
          if (res.data.code === 20000) {
            this.$Message.success({
              content: '新增成功',
            })
            this.callbank()
          } else {
            this.$Message.error({
              content: res.data.msg
            })
          }
        },
      }).post()
    }
  }
}
</script>